package com.linghang.wusthelper.config;

import com.linghang.wusthelper.interceptor.AuthenticationIntercaptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author origin
 * 注册认证拦截器
 */
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(authenticationIntercaptor())
                .addPathPatterns("/**");  //  拦截所有请求
    }

    @Bean
    public AuthenticationIntercaptor authenticationIntercaptor(){
        return new AuthenticationIntercaptor();
    }
}
